Mean sea bass percent larvae contribution.
# load libraries ----
library(tidyverse) # install.packages('tidyverse')
library(raster)
library(leaflet)
select = dplyr::select
stack = raster::stack
r = raster('G:/Team_Folders/Steph/bsb/mean.tif')
d = data_frame(
quantity = raster::getValues(r),
cellid = 1:length(quantity),
area_km2 = 8)
d2 = d %>%
filter(!is.na(quantity)) %>%
arrange(desc(quantity)) %>%
mutate(
pct_quantity = quantity/sum(quantity)*100,
cum_pct_quantity = cumsum(quantity/sum(quantity)*100),
cum_area_km2 = cumsum(area_km2))
#tail(d2) # 7208 km2
#tail(d2$cum_area_km2, 1) # 7208 km2
d3 = d %>%
left_join(d2, by='cellid')
#summary(d3)
r2 = setValues(r, d3$cum_pct_quantity)
binpal <- colorBin("Spectral", seq(0,100), 10, pretty = FALSE, na.color = "transparent")
leaflet() %>%
addTiles() %>%
addProviderTiles('Esri.OceanBasemap') %>%
addRasterImage(r2, colors = binpal, opacity = 0.6) %>%
addMarkers(lat=31.3855157, lng=-80.8843762, popup = "Gray's Reef") %>%
addLegend(
pal = binpal, values = seq(0,100),
title = "cum % larvae")
Mean Red Snapper percent larvae contribution.
# load libraries ----
library(tidyverse) # install.packages('tidyverse')
library(raster)
library(leaflet)
select = dplyr::select
stack = raster::stack
r = raster('G:/Team_Folders/Steph/rs/mean.tif')
d = data_frame(
quantity = raster::getValues(r),
cellid = 1:length(quantity),
area_km2 = 8)
d2 = d %>%
filter(!is.na(quantity)) %>%
arrange(desc(quantity)) %>%
mutate(
pct_quantity = quantity/sum(quantity)*100,
cum_pct_quantity = cumsum(quantity/sum(quantity)*100),
cum_area_km2 = cumsum(area_km2))
#tail(d2) # 7208 km2
#tail(d2$cum_area_km2, 1) # 7208 km2
d3 = d %>%
left_join(d2, by='cellid')
#summary(d3)
r2 = setValues(r, d3$cum_pct_quantity)
binpal <- colorBin("Spectral", seq(0,100), 10, pretty = FALSE, na.color = "transparent")
leaflet() %>%
addTiles() %>%
addProviderTiles('Esri.OceanBasemap') %>%
addRasterImage(r2, colors = binpal, opacity = 0.6) %>%
addMarkers(lat=31.3855157, lng=-80.8843762, popup = "Gray's Reef") %>%
addLegend(
pal = binpal, values = seq(0,100),
title = "cum % larvae")
Mean Scamp percent larvae contribution.
# load libraries ----
library(tidyverse) # install.packages('tidyverse')
library(raster)
library(leaflet)
select = dplyr::select
stack = raster::stack
r = raster('G:/Team_Folders/Steph/sp/mean.tif')
d = data_frame(
quantity = raster::getValues(r),
cellid = 1:length(quantity),
area_km2 = 8)
d2 = d %>%
filter(!is.na(quantity)) %>%
arrange(desc(quantity)) %>%
mutate(
pct_quantity = quantity/sum(quantity)*100,
cum_pct_quantity = cumsum(quantity/sum(quantity)*100),
cum_area_km2 = cumsum(area_km2))
#tail(d2) # 7208 km2
#tail(d2$cum_area_km2, 1) # 7208 km2
d3 = d %>%
left_join(d2, by='cellid')
#summary(d3)
r2 = setValues(r, d3$cum_pct_quantity)
binpal <- colorBin("Spectral", seq(0,100), 10, pretty = FALSE, na.color = "transparent")
leaflet() %>%
addTiles() %>%
addProviderTiles('Esri.OceanBasemap') %>%
addRasterImage(r2, colors = binpal, opacity = 0.6) %>%
addMarkers(lat=31.3855157, lng=-80.8843762, popup = "Gray's Reef") %>%
addLegend(
pal = binpal, values = seq(0,100),
title = "cum % larvae")
Mean Gag percent larvae contribution.
# load libraries ----
library(tidyverse) # install.packages('tidyverse')
library(raster)
library(leaflet)
select = dplyr::select
stack = raster::stack
r = raster('G:/Team_Folders/Steph/gg/mean.tif')
d = data_frame(
quantity = raster::getValues(r),
cellid = 1:length(quantity),
area_km2 = 8)
d2 = d %>%
filter(!is.na(quantity)) %>%
arrange(desc(quantity)) %>%
mutate(
pct_quantity = quantity/sum(quantity)*100,
cum_pct_quantity = cumsum(quantity/sum(quantity)*100),
cum_area_km2 = cumsum(area_km2))
#tail(d2) # 7208 km2
#tail(d2$cum_area_km2, 1) # 7208 km2
d3 = d %>%
left_join(d2, by='cellid')
#summary(d3)
r2 = setValues(r, d3$cum_pct_quantity)
binpal <- colorBin("Spectral", seq(0,100), 10, pretty = FALSE, na.color = "transparent")
leaflet() %>%
addTiles() %>%
addProviderTiles('Esri.OceanBasemap') %>%
addRasterImage(r2, colors = binpal, opacity = 0.6) %>%
addMarkers(lat=31.3855157, lng=-80.8843762, popup = "Gray's Reef") %>%
addLegend(
pal = binpal, values = seq(0,100),
title = "cum % larvae")
Area Required to Attain Target Percent qunatity of Black Sea Bass Larvae
library(tidyverse)
library(raster)
library(plotly)
r = raster('G:/Team_Folders/Steph/bsb/mean.tif')
d = data_frame(
quantity = raster::getValues(r),
cellid = 1:length(quantity),
area_km2 = 8)
d2 = d %>%
filter(!is.na(quantity)) %>%
arrange(desc(quantity)) %>%
mutate(
pct_quantity = quantity/sum(quantity)*100,
cum_pct_quantity = cumsum(quantity/sum(quantity)*100),
cum_area_km2 = cumsum(area_km2))
d3 = d %>%
left_join(d2, by='cellid')
summary(d3)
## quantity.x cellid area_km2.x quantity.y
## Min. :0.000 Min. : 1 Min. :8 Min. :0.000
## 1st Qu.:0.003 1st Qu.: 3052 1st Qu.:8 1st Qu.:0.003
## Median :0.018 Median : 6102 Median :8 Median :0.018
## Mean :0.018 Mean : 6102 Mean :8 Mean :0.018
## 3rd Qu.:0.032 3rd Qu.: 9153 3rd Qu.:8 3rd Qu.:0.032
## Max. :0.050 Max. :12204 Max. :8 Max. :0.050
## NA's :11102 NA's :11102
## area_km2.y pct_quantity cum_pct_quantity cum_area_km2
## Min. :8 Min. :0.000 Min. : 0.251 Min. : 8
## 1st Qu.:8 1st Qu.:0.014 1st Qu.: 52.570 1st Qu.:2210
## Median :8 Median :0.091 Median : 87.151 Median :4412
## Mean :8 Mean :0.091 Mean : 73.477 Mean :4412
## 3rd Qu.:8 3rd Qu.:0.159 3rd Qu.: 99.205 3rd Qu.:6614
## Max. :8 Max. :0.251 Max. :100.000 Max. :8816
## NA's :11102 NA's :11102 NA's :11102 NA's :11102
d_20 = d2 %>% filter(cum_pct_quantity >= 20) %>% head(1)
d_40 = d2 %>% filter(cum_pct_quantity >=40) %>% head(1)
d_60 = d2 %>% filter(cum_pct_quantity >= 60) %>% head(1)
plot(r)
p = ggplot(d2, aes(y=cum_pct_quantity, x=cum_area_km2)) +
xlab("Cumulative Area km2") +
ylab("Cumulative Percent Quantity Larvae") +
ggtitle("Black Sea Bass 2009 - 2015") +
geom_point() +
geom_segment(x=0, xend=d_20$cum_area_km2, y=d_20$cum_pct_quantity, yend=d_20$cum_pct_quantity) +
geom_segment(x=d_20$cum_area_km2, xend=d_20$cum_area_km2, y=0, yend=d_20$cum_pct_quantity) +
geom_segment(x=0, xend=d_40$cum_area_km2, y=d_40$cum_pct_quantity, yend=d_40$cum_pct_quantity) +
geom_segment(x=d_40$cum_area_km2, xend=d_40$cum_area_km2, y=0, yend=d_40$cum_pct_quantity) +
geom_segment(x=0, xend=d_60$cum_area_km2, y=d_60$cum_pct_quantity, yend=d_60$cum_pct_quantity) +
geom_segment(x=d_60$cum_area_km2, xend=d_60$cum_area_km2, y=0, yend=d_60$cum_pct_quantity) +
scale_y_continuous(expand = c(0,0), breaks = c(20,40,60,80,100)) + scale_x_continuous(expand = c(0,0)) +
theme(panel.grid.minor.x = element_blank())
# coord_cartesian(xlim = c(0, tail(d$cum_area_km2, 1)), ylim = c(0, 100))
# print(p)
ggplotly(p)
Area Required to Attain Target Percent qunatity of Red Snapper Larvae
library(tidyverse)
library(raster)
library(plotly)
r = raster('G:/Team_Folders/Steph/rs/mean.tif')
d = data_frame(
quantity = raster::getValues(r),
cellid = 1:length(quantity),
area_km2 = 8)
d2 = d %>%
filter(!is.na(quantity)) %>%
arrange(desc(quantity)) %>%
mutate(
pct_quantity = quantity/sum(quantity)*100,
cum_pct_quantity = cumsum(quantity/sum(quantity)*100),
cum_area_km2 = cumsum(area_km2))
d3 = d %>%
left_join(d2, by='cellid')
summary(d3)
## quantity.x cellid area_km2.x quantity.y
## Min. :0.008 Min. : 1 Min. :8 Min. :0.008
## 1st Qu.:0.021 1st Qu.: 3052 1st Qu.:8 1st Qu.:0.021
## Median :0.026 Median : 6102 Median :8 Median :0.026
## Mean :0.026 Mean : 6102 Mean :8 Mean :0.026
## 3rd Qu.:0.031 3rd Qu.: 9153 3rd Qu.:8 3rd Qu.:0.031
## Max. :0.053 Max. :12204 Max. :8 Max. :0.053
## NA's :11121 NA's :11121
## area_km2.y pct_quantity cum_pct_quantity cum_area_km2
## Min. :8 Min. :0.030 Min. : 0.188 Min. : 8
## 1st Qu.:8 1st Qu.:0.074 1st Qu.: 34.284 1st Qu.:2172
## Median :8 Median :0.093 Median : 61.874 Median :4336
## Mean :8 Mean :0.092 Mean : 58.318 Mean :4336
## 3rd Qu.:8 3rd Qu.:0.110 3rd Qu.: 84.330 3rd Qu.:6500
## Max. :8 Max. :0.188 Max. :100.000 Max. :8664
## NA's :11121 NA's :11121 NA's :11121 NA's :11121
d_20 = d2 %>% filter(cum_pct_quantity >= 20) %>% head(1)
d_40 = d2 %>% filter(cum_pct_quantity >=40) %>% head(1)
d_60 = d2 %>% filter(cum_pct_quantity >= 60) %>% head(1)
plot(r)
p = ggplot(d2, aes(y=cum_pct_quantity, x=cum_area_km2)) +
xlab("Cumulative Area km2") +
ylab("Cumulative Percent Quantity Larvae") +
ggtitle("Red Snapper 2009 - 2015") +
geom_point() +
geom_segment(x=0, xend=d_20$cum_area_km2, y=d_20$cum_pct_quantity, yend=d_20$cum_pct_quantity) +
geom_segment(x=d_20$cum_area_km2, xend=d_20$cum_area_km2, y=0, yend=d_20$cum_pct_quantity) +
geom_segment(x=0, xend=d_40$cum_area_km2, y=d_40$cum_pct_quantity, yend=d_40$cum_pct_quantity) +
geom_segment(x=d_40$cum_area_km2, xend=d_40$cum_area_km2, y=0, yend=d_40$cum_pct_quantity) +
geom_segment(x=0, xend=d_60$cum_area_km2, y=d_60$cum_pct_quantity, yend=d_60$cum_pct_quantity) +
geom_segment(x=d_60$cum_area_km2, xend=d_60$cum_area_km2, y=0, yend=d_60$cum_pct_quantity) +
scale_y_continuous(expand = c(0,0), breaks = c(20,40,60,80,100)) + scale_x_continuous(expand = c(0,0)) +
theme(panel.grid.minor.x = element_blank())
# coord_cartesian(xlim = c(0, tail(d$cum_area_km2, 1)), ylim = c(0, 100))
# print(p)
ggplotly(p)
library(vembedr)
embed_youtube(id="wL-nUjYeMXU", width=672, height=480)